package pers.wwz.study.xmlhttphrequest.common.response;

public class RestResult {

    private Integer code;

    private String message;

    private Object data;

    public RestResult() {
    }

    public RestResult(Integer code, String message, Object data) {
        this.code = code;
        this.message = message;
        this.data = data;
    }

    public RestResult(Integer code, Object data) {
        this.code = code;
        this.data = data;
    }

    public RestResult(Integer code, String message) {
        this.code = code;
        this.message = message;
    }

    public static RestResult SUCCESS(Object data){
        RestResult restResult = new RestResult();
        restResult.setCode(0);
        restResult.setData(data);
        restResult.setMessage("成功");
        return restResult;
    }

    public static RestResult SUCCESS(){
        RestResult restResult = new RestResult();
        restResult.setCode(0);
        restResult.setMessage("成功");
        return restResult;
    }

    public static RestResult FAIL(){
        RestResult restResult = new RestResult();
        restResult.setCode(-999);
        restResult.setMessage("服务器出错");
        return restResult;
    }

    public static RestResult fail(Integer errorCode, String errorMsg) {
        RestResult restResult = new RestResult();
        restResult.setCode(errorCode);
        restResult.setMessage(errorMsg);
        return restResult;
    }

    public Integer getCode() {
        return code;
    }

    public void setCode(Integer code) {
        this.code = code;
    }

    public String getMessage() {
        return message;
    }

    public void setMessage(String message) {
        this.message = message;
    }

    public Object getData() {
        return data;
    }

    public void setData(Object data) {
        this.data = data;
    }
}
